package com.ydd.mapper;

import com.github.pagehelper.Page;
import com.ydd.dto.RolePageDTO;
import com.ydd.dto.UserPageDTO;
import com.ydd.entity.Rewinfo;
import com.ydd.entity.Role;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ydd.vo.RoleVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * <p>
 * 角色表 Mapper 接口
 * </p>
 *
 * @author hgz
 * @since 2023-05-30
 */
@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    @Select("select id from sys_role where name = '超级管理员'")
    String getAdminId();

    @Select("select name from sys_role where id = #{roleId}")
    String findNameById(String roleId);
    Page<RoleVO> page(RolePageDTO rolePageDTO);

    @Insert(" insert into sys_role(id, default_data, superadmin, del_flag, remarks,\n" +
            "                         update_date, create_date, description, name)\n" +
            "    values(#{id}, #{defaultData}, #{superadmin}, #{delFlag}, #{remarks},\n" +
            "           #{updateDate}, #{createDate}, #{description}, #{name})")
    void insert1(Role role1);

    @Delete("delete from sys_role where id = #{id} ")
    void delete1(String id);

    @Select("SELECT default_data AS defaultData, superadmin AS superadmin, del_flag AS delFlag, " +
            "remarks, update_date AS updateDate, create_date AS createDate, description, name " +
            "FROM sys_role WHERE id = #{id}")
    Rewinfo getById(String id);
    int selectBandingUser(String id);

    @Select("select * from sys_role")
    List<Rewinfo> selectall();

    void updateB(Role role1);


    List<String> findByIds(List<String> roleidList);
}
